<template xmlns:v-action="http://www.w3.org/1999/xhtml">
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="48">
          <a-col :md="8" :sm="24">
            <a-form-item label="手机号码">
              <a-input v-model="queryParam.mobile" placeholder="请输入"/>
            </a-form-item>
          </a-col>

          <a-col :md="8" :sm="24">
            <span class="table-page-search-submitButtons">
              <a-button v-action:query type="primary" @click="$refs.table.refresh(true)">查询</a-button>
              <a-button v-action:query style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>


    <s-table
      ref="table"
      size="default"
      :columns="columns"
      :data="loadData"
      :indentSize="40"
    >
       <span slot="avatarUrl" slot-scope="text,record">
          <template>
            <div class="dfhead">
              <img :src="record.avatarUrl" alt="" style="width: 50px;height: auto;">
            </div>
        </template>
      </span>
      <span slot="gender" slot-scope="text,record">
          <template>
              {{record.gender==2?'女':'男'}}
        </template>
      </span>

      <span slot="integral" slot-scope="text,record">
          <template>
<!--              <a  @click="$refs.modal.detail(record)">{{record.integral}}</a>-->
              <a  @click="handleDetail(record)">{{record.integral}}</a>
        </template>
      </span>

      <span slot="action" slot-scope="text, record">
        <template>
          <a  @click="$refs.modal.edit(record)">积分兑换</a>
        </template>
      </span>
    </s-table>

    <Edit ref="modal" @ok="handleOk"></Edit>
  </a-card>
</template>

<script>
  import STable from '@/components/table/'
  import { selectPage } from '../../../api/business/member'
  import Edit from './Edit'
  import Info from '../../business/editor/info'

  export default {
    components: {
      Info,
      STable,
      Edit
    },
    //--############  data() ###############-->
    data() {
      return {
        description: '',
        // 高级搜索 展开/关闭
        advanced: false,
        // 查询参数
        queryParam: {},
        // 表头
        columns: [
          {
            title: '微信头像',
            dataIndex: 'avatarUrl',
            scopedSlots: { customRender: 'avatarUrl' }
          },
          {
            title: '昵称',
            dataIndex: 'nickName'
          },
          {
            title: '性别',
            dataIndex: 'gender',
            scopedSlots: { customRender: 'gender' }
          },
          {
            title: '积分',
            dataIndex: 'integral',
            scopedSlots: { customRender: 'integral' }
          },
          {
            title: '手机号码',
            dataIndex: 'mobile'
          },
          {
            title: 'openid',
            dataIndex: 'openid'
          },
          {
            title: 'openid2',
            dataIndex: 'openid2'
          },
          {
            title: '操作',
            dataIndex: 'action',
            width: '200px',
            scopedSlots: { customRender: 'action' }
          }

        ],
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return selectPage(Object.assign(parameter, this.queryParam))
            .then(res => {
              return res.result
            })
        },

        selectedRowKeys: [],
        selectedRows: []
      }
    },
    //--############  data() ###############-->
    //--############  methods() ###############-->
    methods: {
      toggleAdvanced() {
        this.advanced = !this.advanced
      },
      handleOk() {
        // 新增/修改 成功时，重载列表
        this.$refs.table.refresh(true)
      },
      handleDetail(record){
        this.$emit('onEdit', record)
      }
    }
    //--############  methods() ###############-->
  }
</script>
<style scoped>
  .dfhead{
    width: 50px;
    height: 50px;
    background: url("../../../assets/icons/dfhead.png") no-repeat center;
    background-size: 50px;
    border-radius: 25px;
    overflow: hidden;
  }
</style>